<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>
    // 1. 生成四位随机数字验证码
    // var str = "";
    // for(var i=0;i<4;i++){
    //     str += aaaaa(0,9)
    // }
    // console.log(str);

    // 2. 生成四位随机数字字母混合的验证码
    // 0,9
    // 65,90
    // 97,122
    // 先随机一个大于4位的，每种字符出现次数一致的，随机字符库
    // var randomStr = "";
    // for(var i=0;i<10;i++){
    //     randomStr += aaaaa(0,9);
    //     randomStr += String.fromCharCode(aaaaa(65,90));
    //     randomStr += String.fromCharCode(aaaaa(97,122));
    // }
    // console.log(randomStr);

    // // 从随机字符库中，随机取4位
    // var str = "";
    // for(var i=0;i<4;i++){
    //     str += randomStr[aaaaa(0, randomStr.length-1)]
    // }
    // console.log(str)


    // 3. 生成随机的十六进制的颜色值
    function randomColor(){
        var r = aaaaa(0,255).toString(16);
        var g = aaaaa(0,255).toString(16);
        var b = aaaaa(0,255).toString(16);
        return "#" + createZero(r) + createZero(g) + createZero(b);
    }

    function createZero(n){
        return n.length<2 ? "0"+n : n;
    }

    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())
    console.log(randomColor())







    function aaaaa(max, min){
        return Math.round(Math.random()*(max-min)+min);
    }
</script>
</html>